 //1.公用样式
 require('../../assets/css/index.js')
 //当前页面样式
 require('./login.less')

    //2.公用js
let dom=require('../../utils/dom.js');
let https=require('../../utils/https.js');
let local=require('../../utils/local.js')

    //3.当前页面效果
// console.log(dom);
//相当于文档加载事件
dom.ready(function(){
        console.log('此处省略代码一万行...');

        let logintext=dom.getById('.logintext');

    let loginAccount=dom.getById('#loginAccount');
    let loginPassword=dom.getById('#loginPassword');
    let loginbtn=dom.getById('#loginbtn');
    loginbtn.addEventListener('click',function(){
        if(loginAccount.value==''||loginPassword.value==''){
            alert('请把信息输入完整')
        }else{
        https.post('/api/user/login',{
            account:loginAccount.value,
            password:loginPassword.value
        },function(res){
            console.log(res)
            if(res.errno==0){
                console.log(res)
                local.set('tn',res.data.token);
                local.set('Info',res.data)
                alert('登录成功')
               
                window.location.href='home.html'
            }else{
                alert(res.message)
            }
        })
        }

    })
    logintext.addEventListener('click',function(){
        window.location.href='register.html'
    })





})